#include "TestHashInvoker.h"
#include "HashInvoker.h"

#include <cassert>
#include <iostream>

static void  * setup(){
    HashInvoker * ivk = HashInvoker::create();
    assert(ivk);
    return ivk;
}
static void tear_down(void * setup_ctx ){
    HashInvoker  * ivk  = (HashInvoker*)setup_ctx;
    delete ivk;
}

static void test_isNotExist(void * ctx){
    HashInvoker * ivk = (HashInvoker*)ctx;
    ivk->clear();
    assert(ivk->count() == 0); 
    assert(ivk->isNotExist(100) == true);

    if(ivk->isNotExist(1)){
        assert(ivk->add(1, NULL) == 0);
        assert(ivk->isExist(1) == true);
    }
}

/*
static void test_normal(void * ctx){
    HashInvoker * ivk = (HashInvoker*)ctx;

    long long cmdNullId = 1;
    void * cmdNull = NULL;
    if(ivk->isNotExist(cmdNullId)){
        ivk->add(cmdNullId, cmdNull);
    }
    assert(ivk->count() == 1);

    assert(ivk->run(cmdNullId, cmdNull) == 0);
    assert(ivk->run(cmdNullId, cmdNull) == 0);

    char * c2 = NULL;
    ivk->add(c2);
    assert(ivk->count() == 2);

    delete ivk;
}
*/


void TestHashInvoker(){
    void * ctx = setup();
    
    test_isNotExist(ctx);
//    test_normal();

    tear_down(ctx);
}
